//从cookie中获取标题 网址
var id=$.cookie("MYID");
var newstitle=$.cookie("newstitle");
var newsurl=$.cookie("newsurl");
$("#newsiframe").attr("src",newsurl);
$("#sharetitleword div").html(newsurl);
//详情页面分享操作
var cansend=1;// 1可以转发 0不可以转发
$("#iframesharebtn").click(function(e){
    console.log(cansend);
    //console.log(newstitle);
    //var newsid= e.target.dataset.newsid;
    var newsid= $.cookie("newsid");
    $("#sharetitleword div").html(newstitle);
    $("#seenews").css("display","none");
    $("#shareword").css("display","block");
    //转发确定按钮
    if(cansend==1){
        console.log(cansend);
        sendcommentbtn.onclick=function(){
            cansend=0;
            sendcommentbtn.disabled=true;
            if(commentinput.value){
                if(commentinput.value.match(/^\s+$/g)){
                    //console.log("one part");
                    $("#sharewaiting").css("display","block");
                    $.ajax({
                        type:"post",
                        datatype:"json",
                        url:addshareurl,
                        data:{"contentid":newsid,"userid":id,"fromuser":"","des":"","contenttype":1},
                        success:function(data){
                            console.log(data);
                            commentinput.value="";
                            shareword.style.display="none";
                            $("#seenews").css("display","block");
                            $("#collectword").css("display","block");
                            setTimeout(function(){
                                $("#sharewaiting").css("display","none");
                                $("#collectword").css("display","none");
                            },1000);
                            clearTimeout();
                            cansend=1;
                            sendcommentbtn.disabled=false;
                        }
                    })
                }else{
                    console.log("two part");
                    $("#sharewaiting").css("display","block");
                    $.ajax({
                        type:"post",
                        datatype:"json",
                        url:addshareurl,
                        data:{"contentid":newsid,"userid":id,"fromuser":"","des":commentinput.value,"contenttype":1},
                        success:function(data){
                            console.log(data);
                            commentinput.value="";
                            shareword.style.display="none";
                            $("#seenews").css("display","block");
                            $("#collectword").css("display","block");
                            setTimeout(function(){
                                $("#sharewaiting").css("display","none");
                                $("#collectword").css("display","none");
                            },1500);
                            clearTimeout();
                            cansend=1;
                            sendcommentbtn.disabled=false;
                        }
                    })
                }
            }else{
                console.log("three part");
                $("#sharewaiting").css("display","block");

                $.ajax({
                    type:"post",
                    datatype:"json",
                    url:addshareurl,
                    data:{"contentid":newsid,"userid":id,"fromuser":"","des":"","contenttype":1},
                    success:function(data){
                        console.log(data);
                        commentinput.value="";
                        shareword.style.display="none";
                        $("#collectword").css("display","block");
                        $("#seenews").css("display","block");
                        var timer3=setTimeout(function(){
                            $("#sharewaiting").css("display","none");
                            $("#collectword").css("display","none");
                        },1500);
                        cansend=1;
                        sendcommentbtn.disabled=false;
                    }
                })
            }
        };
    }
    //取消
    cancelbtn.onclick=function(){
        commentinput.value="";
        $("#seenews").css("display","block");
        shareword.style.display="none";
    }
});
//返回按钮
$("#iframegoback").click(function(){
    history.go(-1);
});
$("#sharegoback").click(function(){
    $("#shareword").css("display","none");
    $("#seenews").css("display","block");
});